package com.da.javatest.leetCode;

import java.util.Arrays;

/**
 * @author chenlida
 * @date 2019/1/21 14:31
 * @description
 */
public class Code611 {
    public static void main(String[] args) {
        new Code611().triangleNumber(new int[] {2, 2, 3, 4});
    }

    public int triangleNumber(int[] nums) {
        int total = 0;
        Arrays.sort(nums);
        for (int i = 0; i < nums.length; i++) {
            for (int j = i + 1; j < nums.length; j++) {
                for (int k = j + 1; k < nums.length; k++) {
                    if (nums[i] + nums[j] > nums[k]) {
                        total++;
                    } else {
                        break;
                    }
                }
            }
        }
        return total;
    }
}
